﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Collections;
using Webchatting.Common;
using Webchatting.Dal;


public partial class server_GroupInfoEdit : System.Web.UI.Page
{
    public static ArrayList arrGroupIds = new ArrayList();
    public static ArrayList arrGroupNames = new ArrayList();
    public static ArrayList arrGroupDess = new ArrayList();

    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnListMyGroup_Click(object sender, EventArgs e)
    {
        

        int selected = ddlSelectGroup.SelectedIndex;
        FormsIdentity id = (FormsIdentity)User.Identity;

        OperationGroup Ogroup = new OperationGroup();
        string serachGroups = Ogroup.LoadGroupDetail(id.Ticket.UserData.Split('@')[0], arrGroupIds, arrGroupNames,  arrGroupDess);

        ltlResult.Text = "<b>我的群：</b><br/>" + serachGroups;
        ltlText.Text = "<b>请选择要操作的群ID：</b>";
        btnEditGroupdetails.Visible = true;
        
        ddlSelectGroup.Visible = true;
        txtGroupDes.Visible = true;
        txtGroupName.Visible = true;
        ltlGroupDes.Visible = true;
        ltlGroupName.Visible = true;
        while (ddlSelectGroup.Items.Count > 0)
        {
            ddlSelectGroup.Items.RemoveAt(0);
        }

        for (int i = 0; i < arrGroupIds.Count; i++)
        {
            ddlSelectGroup.Items.Add(new ListItem((string)arrGroupIds[i], (string)arrGroupIds[i]));
        }
        
    }

   
    
    protected void btnEditgroupdetails_Click(object sender, EventArgs e)
    {
        FormsIdentity id = (FormsIdentity)User.Identity;
        OperationGroup Ogroup3 = new OperationGroup();
        int selected = ddlSelectGroup.SelectedIndex;
        try
        {

            Ogroup3.ModifyGroupDetails(id.Ticket.UserData.Split('@')[0], arrGroupIds[selected].ToString(), txtGroupName.Text.Trim(), txtGroupDes.Text.Trim());
           
           Response.Write("<script>alert('修改成功!');window.parent.location.href='RUIndex.aspx';</script>");

        }
        catch
        {
           Javascript.GoHistory(-1, "修改失败！", Page);
        }
    }
   
}
